import request from '@/utils/request'

const personalApi = {
  basicInfo: '/api/setting/basicInfo',
  personalTags: '/api/personal/tags',
  personalUserinfo: "/api/app/userinfo",
}

class Service {
  /**
   * @description POST 设置基本信息
   */
  static postSetBasicInfo(data: any) {
    return request({
      url: personalApi.basicInfo,
      method: 'post',
      json: true,
      data
    }).then((res) => {
      if (res.status === 0) {
        return Promise.resolve(res)
      }
      return Promise.reject(res)
    })
  }

  /**
   * @description Get 获取tags
   */
  static getPersonTags() {
    return request({
      url: personalApi.personalTags,
      method: 'get',
      json: true
    }).then((res) => {
      if (res.status === 0) {
        return Promise.resolve(res)
      }
      return Promise.reject(res)
    })
  }


  /*
    获取全部用户信息
  */
  static getPersonUserinfo() {
    return request({
      url: personalApi.personalUserinfo,
      method: 'get',
      json: true
    }).then((res) => {
      if (res.code === 200) {
        return Promise.resolve(res)
      }
      return Promise.reject(res)
    })
  }


  /*
    添加新用户
  */
  static postPersonUserinfo(data: any) {
    return request({
      url: personalApi.personalUserinfo,
      method: 'post',
      json: true,
      data
    }).then((res) => {
      if (res.code === 200) {
        return Promise.resolve(res)
      }
      return Promise.reject(res)
    })
  }
  

  /*
    修改用户
  */
  static editPersonUserinfo(data: any) {
    return request({
      url: personalApi.personalUserinfo,
      method: 'put',
      json: true,
      data
    }).then((res) => {
      if (res.code === 200) {
        return Promise.resolve(res)
      }
      return Promise.reject(res)
    })
  }

  /*
    删除用户
  */
    static deletePersonUserinfo(data: any) {
      return request({
        url: `/api/app/userinfo?id=${data}`,
        method: 'delete',
        json: true,
      }).then((res) => {
        if (res.code === 200) {
          return Promise.resolve(res)
        }
        return Promise.reject(res)
      })
    }


}
export default Service
